public class Main {
    public static void main(String[] args) {
        String s = "小白Java";
        // 获取字符串的长度
        System.out.println(s.length()); // 6
        // 提取字符串中某个索引位置处的字符
        char c = s.charAt(1);
        System.out.println(c);// 白

        // 字符串遍历
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            System.out.println(ch);
        }

        // 字符数组遍历
        char[] chars = s.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            System.out.println(chars[i]);
        }

        String s1 = new String("白");
        String s2 = new String("小白");
        System.out.println(s1 == s2); // false，地址不一样
        System.out.println(s1.equals(s2)); // true


        String c1 = "34AeFG";
        String c2 = "34aEfg";
        System.out.println(c1.equals(c2)); // false，内容必须一样
        System.out.println(c1.equalsIgnoreCase(c2)); // true
    
        String s3 = "Java是最好的编程语言之一";
        String rs = s3.substring(0, 8);
        System.out.println(rs); // Java是最好的


        String s4 = "Java是最好的编程语言之一";
        String rs2 = s4.substring(5);
        System.out.println(rs2); // 最好的编程语言之一


        String info = "这个电影简直是个垃圾，垃圾电影!!";
        String rs3 = info.replace("垃圾", "**");
        System.out.println(rs3); // 这个电影简直是个**，**电影!!



        String info2 = "Java尼最好的编程语言之一，我就!ava,Java不爱我!";
        System.out.println(info2.contains("Java"));
        System.out.println(info2.contains("java"));
        System.out.println(info2.contains("Java2"));


        String rs4 = "张三丰";
        System.out.println(rs4.startsWith("张")); // true
        System.out.println(rs4.startsWith("张三")); // true
        System.out.println(rs4.startsWith("张三丰")); // 


        String rs5 = "张无忌,周芷若,殷素素,赵敏";
        String[] names = rs5.split(",");
        for (int i = 0; i < names.length; i++) {
            System.out.println(names[i]);
        }
    }
}
